package com.example.hospitalapp;

import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import org.json.JSONObject;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

public class PrescriptionActivity extends AppCompatActivity {

    private TextView txtMedicationName, txtQuantity, txtTotalCost;
    private Button btnPay;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_prescription);

        txtMedicationName = findViewById(R.id.txtMedicationName);
        txtQuantity = findViewById(R.id.txtQuantity);
        txtTotalCost = findViewById(R.id.txtTotalCost);
        btnPay = findViewById(R.id.btnPay);

        // 获取传递过来的药品信息
        String medicationName = getIntent().getStringExtra("medicationName");
        int quantity = getIntent().getIntExtra("quantity", 0);
        double totalCost = getIntent().getDoubleExtra("totalCost", 0);

        // 显示药品信息
        txtMedicationName.setText("药品名称: " + medicationName);
        txtQuantity.setText("数量: " + quantity);
        txtTotalCost.setText("总费用: ¥" + totalCost);

        // 点击缴费按钮
        btnPay.setOnClickListener(v -> {
            // 创建支付记录
            createPaymentRecord(totalCost);
        });
    }

    private void createPaymentRecord(double totalCost) {

        Toast.makeText(PrescriptionActivity.this, "支付成功", Toast.LENGTH_SHORT).show();
        finish();

    }

}
